// packageEducation/pages/detail/detail.js
import {getDetail} from "../../../service/Education"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        isLoading: true,
        detail: {}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getEducationDetail(options.id)
    },

    /*
    * 获取详情
    *
    * */
    getEducationDetail: async function (id) {
        try {
            let res = await getDetail(id);
            let content = res.content.replace(/\<o:p\>/gi, '');
            content = content.replace(/\<o:p\>\/>/gi, '');
            this.setData({
                detail: {
                    title: res.title,
                    content: content,
                    time: res.time
                }
            })
        } catch (e) {
            console.error(e)
        } finally {
            this.setData({isLoading: false})
        }
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})